<?php
class forms_RegistrationForm extends Zend_Form {

    public function  __construct($options = null) {

        parent::__construct($options);

        $this->setAction('/user/register-process')
            ->setMethod('post')
            ->setAttrib('name','register')
            ->setAttrib('id','register');

            $firstName = new Zend_Form_Element_Text('register_firstname');
            $firstName->setRequired(true)
            ->setLabel('first name');
            
            $lastName = new Zend_Form_Element_Text('register_lastname');
            $lastName->setRequired(true)
            ->setLabel('last name');

            $username = new Zend_Form_Element_Text('register_username');
            $username->addValidator(new Zend_Validate_Alnum())
            ->setRequired('true')
            ->addFilter('StringtoLower')
            ->setLabel('username');


            $password = new Zend_Form_Element_Password('register_password', array(
                'validators'=> array(
                        'Alnum',
                        array('StringLength', array(6,20))
                        ),
                'filters'       => array('StringTrim'),
                'label'         => 'password'
                ));
            
            $password2 = new Zend_Form_Element_Password('register_password2', array(
                'validators'=> array(
                        'Alnum',
                        array('StringLength', array(6,20))
                        ),
                'filters'       => array('StringTrim'),
                'required'      => true,
                'label'         => 'password again'
                ));
            
            $options = array('m'=>'male','f'=>'female');
            $gender = new Zend_Form_Element_Radio('register_gender');
            $gender->setRequired(true)
            ->setValue('m')
            ->setLabel('gender')
            ->setMultiOptions($options);

            $email = new Zend_Form_Element_Text('register_email');
            $email->setLabel('email')
            ->setRequired(true)
            ->addValidator(new Zend_Validate_EmailAddress());

            $birthday = new Zend_Form_Element_Text('register_birthday');
            $birthday->setLabel('birthday (YYYY-MM-DD)')
            ->setRequired(true)
            ->addValidator(new Zend_Validate_Date());

            $submit = new Zend_Form_Element_Submit('submit');
            $submit->setLabel('Register');

            $this->addElements(array($gender,$firstName,$lastName,$username,$password,$password2,$email,$birthday,$submit));

    }

}